import request from "@/utils/request"

// 查询订单列表
export function listOrder(query) {
  return request({
    method: 'get',
    params: query,
    url: "/orderEdit/list"
  })
}

/**
 * 编辑上传 稿件
 */
export function uploadTranslateFile(id, params, component) {
  return request({
    url: `/orderEdit/uploadManuscripts/${id}`,
    method: 'put',
    data: params
  }).then(res => {
    component.$message.success(res.msg);
    component.$emit('receiveData', params);
    component.$emit('close', false);
  })

}


// 查询订单列表
export function listOrderQuery(query) {
  return request({
    method: 'get',
    params: query,
    url: "/orderEdit/listQuery"
  })
}


export function assignOrder(param, component) {
  return request({
    url: '/orderEdit/assignOrder',
    method: 'post',
    data: param
  }).then(res => {
    component.$message.success(res.msg);
    component.$emit('receiveData', param);
    component.$emit('close', false);
  })
}

/**
 * 开始处理
 * @param {{}} param 
 * @param {import("element-ui").Component} component 
 */
export function parseByStart(param, component) {
  return request({
    url: `/orderEdit/parseByStart/${param.id}`,
    method: 'put',
  }).then(res => {
    component.$message({
      message: res.msg, 
      type: 'success' 
   });
  })
}

/**
 * 根据 userid 获取 关联数据
 * @param {{}} query 
 * @returns 
 */
export function listOrderByUserId(query) {
  return request({
    url: '/orderEdit/listByUser',
    method: 'get',
    params: query
  })
}

/**
 * 根据 userid 获取余额支付的 关联数据
 * @param {{}} query 
 * @returns 
 */
export function listRechargeByUser(query) {
  return request({
    url: '/orderEdit/listRechargeByUser',
    method: 'get',
    params: query
  })
}



// 查询订单详细
export function getOrder(id) {
  return request({
    url: '/orderEdit/' + id,
    method: 'get'
  })
}

// 新增订单
export function addOrder(data) {
  return request({
    url: '/orderEdit',
    method: 'post',
    data: data
  })
}

// 修改订单
export function updateOrder(data) {
  return request({
    url: '/orderEdit',
    method: 'put',
    data: data
  })
}

// 报账合同
export function updateContractOrder(data) {
  return request({
    url: '/orderEdit/updateContract',
    method: 'put',
    data: data
  })
}


// 翻译证明
export function updateTranslationProofOrder(data) {
  return request({
    url: '/orderEdit/updateTranslationProofContract',
    method: 'put',
    data: data
  })
}

/**
 * @param {{}} data 
 * @returns 
 */
export function quotation(data, url="/orderEdit/quotation") {
  return request.put(
    url,
    data
  )
}

/**
 * 备注
 * @param {{}} data 
 * @returns 
 */
export function ktRemark(data) {
  return request.put(
    '/orderEdit/ktRemark',
    data
  )
}



// 删除订单
export function delOrder(id) {
  return request({
    url: '/orderEdit/' + id,
    method: 'delete'
  })
}
